import Vue from 'vue';

export function request(param) {
  return new Promise((resolve, reject) => {
    Vue.prototype.$http(param)
      .then((response) => {
        if (response.data.code == 200) {
          resolve(response.data);
        } else {
          reject(response.data);
          console.log(response.data)
          Vue.prototype.$message({
            showClose: true,
            message: response.data.message,
            type: "error",
          });
        }
      })
      .catch((error) => {
        console.log(error)
        Vue.prototype.$message({
          showClose: true,
          message: error,
          type: "error",
        });
      });
  });
}